package xyz.xuminghai.javafx_learn.scene.control;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ColorPicker;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.stage.Stage;

/**
 * 2023/1/17 13:11 星期二<br/>
 *
 * @author xuMingHai
 */
public class ColorPickerApp extends Application {

    private final AnchorPane anchorPane = new AnchorPane();

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void init() {
        ColorPicker colorPicker = new ColorPicker();
        colorPicker.setOnAction(event -> anchorPane.setBackground(new Background(
                new BackgroundFill(colorPicker.getValue(), null, null)
        )));
        // TODO: 自定义颜色，点击保存会最小化窗体
        anchorPane.getChildren().add(colorPicker);
    }

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle(getClass().getSimpleName());
        primaryStage.setScene(new Scene(anchorPane, 800, 600));
        primaryStage.show();
    }
}
